Network devices, such as routers, may employ a memory and a number of queues. The queues may be associated with, for example, receiving traffic from a network or making traffic available to a network. In certain implementations, there may be a large number of queues sharing a common memory. In these implementations, the memory may be insufficient to meet the storage needs of all of the queues operating on the device if the queues are operating at, or near, capacity, such as near maximum fill rates. Assume that a network device has a memory that is 15 megabytes (Mbytes) in size. Further assume that this memory is shared across ten queues each having a size of 2 Mbytes. If all of the queues attempt to operate near maximum fill rates (2 Mbytes/queue), the 15 Mbyte memory will be incapable of meeting the approximately 20 Mbyte (10 queues×2 Mbyte/queue) storage requirements for the ten queues. If a memory cannot meet the storage needs of some, or all, of the queues, packets may be dropped.
Network devices having insufficient memory to service the demands of queues may attempt to manage memory so that each queue is treated fairly with respect to the other queues. Fair treatment of queues may reduce the chances that a queue is treated unfairly, such as by dropping a disproportionate number of packets associated with the queue. Queue and/or memory management techniques may use thresholds and a single unit of queue management, such as a buffer. Buffers may be used to store data units associated with queues. The threshold may be used to allocate buffers to queues in a manner that attempts to maintain parity across the queues. Managing queues using buffers may be inefficient if incoming data units are smaller in size than a buffer. For example, if a buffer is 128 bytes in size and an incoming packet is 40 bytes in size, the packet may be allocated 128 bytes of memory when placed in a queue since a 128 byte buffer is the increment used for operating with queues. If a queue is receiving large numbers of small packets, the queue may be deprived of additional buffers as the queue nears the threshold even though the actual number of bytes stored in the queue may not be very large relative to the capacity of the queue.
Memory management in network devices may benefit from techniques that dynamically adjust queue management units based on a number of queues in operation, the state of operating queues, thresholds associated with queues, and/or other parameters, such as congestion, packet priorities, queue profiles, etc.